package com.slkj.shilixiaoyuanapp.data.room;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;


import com.slkj.shilixiaoyuanapp.SlxyApplication;
import com.slkj.shilixiaoyuanapp.data.room.dao.UserDao;
import com.slkj.shilixiaoyuanapp.entity.UserDataBaseEntity;

/**
 * Created  on 2018/4/3
 * @author 唐开阔
 * @describe
 */
@Database(entities = {UserDataBaseEntity.class}, version = 1, exportSchema = false)
public abstract class AppDataBase extends RoomDatabase {
    private static AppDataBase ourInstance;
    public static synchronized AppDataBase getInstance() {
        if (ourInstance == null) {
            ourInstance = Room.databaseBuilder(SlxyApplication.getContext(),
                    AppDataBase.class, "shilixiaoyuan")
                    .addMigrations()
                    .allowMainThreadQueries()
                    .build();
        }
        return ourInstance;
    }
    public abstract UserDao getUserDao();


    /**
     * 清空所有数据
     */
    public void deleteDataBase(){
//        getUserDao().deleteAll(getUserDao().getAll());
    }


}
